package subject_set.interview.Day1_28_meituan;

import java.util.HashMap;
import java.util.Map;

/**
 * @author haomin
 * @date 2023/01/29 16:00
 **/
import java.util.*;
public class Main2 {
    public PriorityQueue fun(String str) {
        Map<Character, Integer> map = new HashMap<>();
        for(char c : str.toCharArray()) {
            if(map.containsKey(c)) map.put(c, map.get(c) + 1);
            else map.put(c, 1);
        }
        PriorityQueue<int[]> res = new PriorityQueue<>((a, b) -> (b[1] - a[1]));
        for(Map.Entry<Character, Integer> m : map.entrySet()) {
            int[] arr  = new int[2];
            arr[0] = m.getKey();
            arr[1] = m.getValue();
            res.add(arr);
        }
        return res;
    }
}